package com.iflytek.esb.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import net.sf.json.JSONObject;

public class Trace implements Serializable {

	private static final long serialVersionUID = -8841204937913371917L;
	private long id;
	private long entryId;
	private String entryName;
	private int actionId;
	private String actionName;
	private Date time;
	private Map<String, String> messageHeaders = new HashMap<String, String>();
	private String messageContent;
	private boolean hasExeption;
	private String exceptionMessage;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getEntryId() {
		return entryId;
	}

	public void setEntryId(long entryId) {
		this.entryId = entryId;
	}

	public String getEntryName() {
		return entryName;
	}

	public void setEntryName(String entryName) {
		this.entryName = entryName;
	}

	public int getActionId() {
		return actionId;
	}

	public void setActionId(int actionId) {
		this.actionId = actionId;
	}

	public String getActionName() {
		return actionName;
	}

	public void setActionName(String actionName) {
		this.actionName = actionName;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public Map<String, String> getMessageHeaders() {
		return messageHeaders;
	}

	public void setMessageHeaders(Map<String, String> messageHeaders) {
		this.messageHeaders = messageHeaders;
	}

	public String getMessageContent() {
		return messageContent;
	}

	public void setMessageContent(String messageContent) {
		this.messageContent = messageContent;
	}

	public boolean isHasExeption() {
		return hasExeption;
	}

	public void setHasExeption(boolean hasExeption) {
		this.hasExeption = hasExeption;
	}

	public String getExceptionMessage() {
		return exceptionMessage;
	}

	public void setExceptionMessage(String exceptionMessage) {
		this.exceptionMessage = exceptionMessage;
	}

	public String getMessageHeaders__() {
		JSONObject json = JSONObject.fromObject(messageHeaders);
		return json.toString();
	}
	
	@SuppressWarnings("unchecked")
	public void setMessageHeaders__(String messageHeaders__) {
		JSONObject json = JSONObject.fromObject(messageHeaders__);
		Iterator<String> iter = json.keys();
		while (iter.hasNext()) {
			String key = iter.next();
			String value = json.getString(key);
			messageHeaders.put(key, value);
		}
	}
}
